<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<link rel="stylesheet"  type="text/css"  href="bootstrap.css" >
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        html {
            height: 100%;
        }
        body {
            background:url(https://img.51miz.com/Element/00/59/33/44/6766b1bb_E593344_6baa5e03.jpg)no-repeat center center;
            height: 100%;
            width: 100%;
            background-size:cover;
            position:absolute;
            left:0;
            top:0
        }
    </style>
</head>
<body>
<div class="container">
    <div class="col-md-4"></div>
    <div class="col-md-4" style="background-color:#eee;;margin-top:200px;">
        <center>
            <h3>添加教师</h3>
        </center>
        <form id="form-login" action="login" method="post">
            <div class="form-group">
                <label for="xingming">姓名:</label>
                <input type="text"  name="xingming" id="xingming" value="" class="form-control" style="color:red;">
            </div>
            <div class="form-group">
                <label for="nianling">年龄</label>
                <input type="number"  name="nianling" id="nianling" value="" class="form-control" style="color:red;">
            </div>
            <div class="form-group">
                <label for="zhicheng">职称</label>
                <input type="text"  name="zhicheng" id="zhicheng" value="" class="form-control" style="color:red;">
            </div>
            <div class="form-group">
                <input type="button" onclick="f2()" value="返回" class="btn btn-primary">
                <input type="button" onclick="f1()" value="添加" class="btn btn-primary">
            </div>

        </form>
    </div>
    <div class="col-md-4"></div>
</div>
</body>
</html>
<script>
    function f2(){
        window.location.href="main.html";
    }
    function f1(){
        var xingming = $("#xingming").val();
        var nianling = $("#nianling").val();
        var zhicheng = $("#zhicheng").val();
        if(xingming==""||nianling==""||zhicheng==""){
            alert("请输入完整信息");
            return;
        }
        $.ajax({
            "url":"/addJiaoshi",
            "data": {
                'xingming':xingming,
                'nianling':nianling,
                'zhicheng':zhicheng
            },
            "type":"post",
            "dataType":"text",
            "success":function(json) {
                alert(json);
                if("添加成功"==json){
                    window.location.href="main.html";
                }else{
                    $("#xingming").val("");
                    $("#nianling").val("");
                    $("#zhicheng").val("");
                }
            }
        });
    }
</script>